package com.java.comprehensive.arithmetic.leecode.easy;

import java.util.Arrays;

public class LeetCode_344 {
    public static void reverseString(char[] s) {
        if (s.length > 1) {
            int l = 0;
            int r = s.length - 1;
            while (l < r) {
                swap(s, l, r);
                l++;
                r--;
            }
        }
    }

    private static void swap(char[] s, int l, int r) {
        char temp = s[l];
        s[l] = s[r];
        s[r] = temp;
    }

    public static void main(String[] args) {
        char[] s = {'h', 'e', 'l', 'l', 'o'};
        reverseString(s);
        System.out.println(Arrays.toString(s));
    }
}
